this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};(function(t,e,i){"use strict";class n extends Node{constructor(t){super();this.trim=BX.Landing.Utils.trim;this.isPlainObject=BX.Landing.Utils.isPlainObject;this.isString=BX.Landing.Utils.isString;this.textToPlaceholders=BX.Landing.Utils.textToPlaceholders;this.create=BX.Landing.Utils.create;this.escapeText=BX.Landing.Utils.escapeText;this.decodeDataValue=BX.Landing.Utils.decodeDataValue;BX.Landing.Block.Node.apply(this,arguments);this.type="link";if(!this.isGrouped()){this.node.addEventListener("click",this.onClick.bind(this))}if(this.isAllowInlineEdit()){this.node.setAttribute("title",BX.Landing.Loc.getMessage("LANDING_TITLE_OF_LINK_NODE"))}}onContentUpdate(){var t=this.getBlock().id;clearTimeout(this.contentEditTimeout);this.contentEditTimeout=setTimeout(function(){BX.Landing.History.getInstance().push(new BX.Landing.History.Entry({block:t,selector:this.selector,command:"editLink",undo:this.startValue,redo:this.getValue()}));this.startValue=null}.bind(this),400);this.getField().setValue(this.getValue())}isMenuMode(){return this.manifest.menuMode===true}onClick(){event.preventDefault();if(!this.isMenuMode()){event.stopPropagation()}if(this.isAllowInlineEdit()){BX.Landing.UI.Button.ColorAction.hideAll();if(!BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){const t=new i.PanelLink;t.getInstance().show(this);BX.Landing.UI.Panel.Link.getInstance().show(this)}}}isPrevented(){return this.getValue().target==="_popup"}setValue(t,e,i){this.startValue=this.startValue||this.getValue();this.preventSave(e);if(!this.containsImage()&&this.isAllowInlineEdit()){var n=this.getField(true).hrefInput;if(this.isString(t.text)&&t.text.includes("{{name}}")){n.getPlaceholderData(t.href).then(function(e){this.node.innerHTML=t.text.replace(new RegExp("{{name}}"),'<span data-placeholder="name">'+e.name+"</span>")}.bind(this))}else{if(!this.getField().containsHtml()&&!this.manifest.skipContent){this.node.innerHTML=this.escapeText(t.text)}}}this.node.setAttribute("href",this.decodeDataValue(t.href));this.node.setAttribute("target",this.escapeText(t.target));if("attrs"in t){for(var s in t.attrs){if(t.attrs.hasOwnProperty(s)){this.node.setAttribute(s,t.attrs[s])}}}else{this.node.removeAttribute("data-url");this.node.removeAttribute("data-embed")}this.onChange();if(!i){this.onContentUpdate()}}containsImage(){return!!this.node.firstElementChild&&this.node.firstElementChild.tagName==="IMG"}getValue(){var t={text:this.textToPlaceholders(this.trim(this.node.innerHTML)),href:this.trim(this.node.getAttribute("href")),target:this.trim(this.node.getAttribute("target")||"_self")};if(this.node.getAttribute("data-url")){t.attrs={"data-url":this.trim(this.node.getAttribute("data-url"))}}if(this.node.getAttribute("data-dynamic")){if(!this.isPlainObject(t.attrs)){t.attrs={}}t.attrs["data-dynamic"]=this.node.getAttribute("data-dynamic")}if(this.manifest.skipContent){t["skipContent"]=true;delete t.text}return t}getField(t){var e=this.getValue();e.text=this.textToPlaceholders(this.create("div",{html:e.text}).innerHTML);if(!this.field){var i=[BX.Landing.UI.Field.LinkUrl.TYPE_BLOCK,BX.Landing.UI.Field.LinkUrl.TYPE_PAGE,BX.Landing.UI.Field.LinkUrl.TYPE_CRM_FORM,BX.Landing.UI.Field.LinkUrl.TYPE_CRM_PHONE];if(BX.Landing.Main.getInstance().options.params.type===BX.Landing.Main.TYPE_STORE){i.push(BX.Landing.UI.Field.LinkUrl.TYPE_CATALOG)}if(BX.Landing.Main.getInstance().options.features.includes("diskFile")){i.push(BX.Landing.UI.Field.LinkUrl.TYPE_DISK_FILE)}this.field=new BX.Landing.UI.Field.Link({title:this.manifest.name,selector:this.selector,skipContent:this.manifest.skipContent,content:e,options:{siteId:BX.Landing.Main.getInstance().options.site_id,landingId:BX.Landing.Main.getInstance().id},allowedTypes:i})}else{if(!t){this.field.setValue(e);this.field.content=e;this.field.hrefInput.content=e.href;this.field.hrefInput.makeDisplayedHrefValue();this.field.hrefInput.setHrefTypeSwitcherValue(this.field.hrefInput.getHrefStringType());this.field.hrefInput.removeHrefTypeFromHrefString()}}return this.field}}t.Link=n})(this.BX.Landing.Node=this.BX.Landing.Node||{},BX,BX.Landing.Ui.Panel);
//# sourceMappingURL=link.bundle.map.js